﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="ConfigAE.aspx.cs" Inherits="Admin_Modules_Config_ConfigAE" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <%---------------%>
    <div class="header" style="width: 1200px; text-align: left">
            THÊM CHI TIẾT CONFIG
            <div class="content-IE">
            
    <table class="adminContent">

        <tr>
            <td class="adminTitle">Title
            </td>
            <td class="adminData">
                <asp:TextBox runat="server" ID="txtName" CssClass="adminInput" />
            </td>
        </tr>
        <tr>
            <td class="adminTitle">Chi tiết
            </td>
            <td class="adminData">
                <asp:ScriptManager ID="ScriptManager1" runat="server" />
                <telerik:RadEditor Width="835" Height="900" ID="radEditorContent" ToolsFile="~/App_Data/Xml/DefaultToolbar.xml"
                    runat="server" Skin="Default" EditModes="All" NewLineBr="True" EnableEmbeddedScripts="true"
                    StripFormattingOptions="Css,Font,Span,MSWord,MSWordNoFonts,MSWordRemoveAll" StripFormattingOnPaste="Css,Font,Span,MSWord,MSWordNoFonts,MSWordRemoveAll"
                    ToolbarMode="Default" SpellCheckSettings-AllowAddCustom="false" EnableResize="false"
                    OnClientCommandExecuted="OnClientCommandExecuted" OnClientPasteHtml="OnClientPasteHtml1"
                    ContentFilters="DefaultFilters">
                    <CssFiles>
                        <telerik:EditorCssFile Value="/css/Editor.css" />
                    </CssFiles>
                </telerik:RadEditor>
            </td>
        </tr>
    </table>
     <div class="section-header">
        <div class="options">
            <asp:Button ID="btnSave" runat="server" CssClass="adminButtonBlue" Text="Cập nhật" ToolTip="Save"
                OnClick="btnSave_Click" />
            <a href="ConfigList.aspx" style="cursor: pointer">
                <input type="button" class="adminButtonBlue" value="Danh sách chi tiết tour" />
            </a>&nbsp;
        </div>
    </div>
            </div>
            <div class="clear">
            </div>
        </div>
    <%---------------%>
    <script  type="text/javascript">
        var regexWhiteSpace = new RegExp("<(p[^>]*)>(((\&nbsp;)*\s*)*)?</p>|<(p[^>]*)><(span[^>]*)>(((\&nbsp;)*\s*)*)?</span></p>|<(font[^>]*)>|<(/font[^>]*)>|<o:p>|</o:p>|<(st1[^>]*)>|<(/st1[^>]*)>|&nbsp;", "gi");
        var regexP = new RegExp("(<p|<P)[^>]*>(.*?)(<\/P>|<\/p>)", "gi");
        var regexOpenDIV = new RegExp("(<div|<DIV)[^>]*>", "gi");
        var regexCloseDIV = new RegExp("(<\/DIV>|<\/div>)", "gi");
        var regexSpan = new RegExp("(<span[^*>]*>)|(<\/span>)|(<SPAN[^*>]*>)|(<\/SPAN>)", "gi");
        /*var regexFont = new RegExp("(<font[^*>]*>)|(<\/font>)|(<FONT[^*>]*>)|(<\/FONT>)", "gi");*/
        var regexFont = new RegExp("(<font|<FONT)[^>]*>(.*?)(<\/FONT>|<\/font>)", "gi");
        var regexStrong = new RegExp("(<strong[^*>]*>)|(<\/strong>)|(<STRONG[^*>]*>)|(<\/STRONG>)", "gi");
        var regexB = new RegExp("(<b|<B)[^>]*>(.*?)(<\/B>|<\/b>)", "gi");
        var regexU = new RegExp("(<u|<U)[^>]*>(.*?)(<\/U>|<\/u>)", "gi");
        var regexI = new RegExp("(<i|<I)[^>]*>(.*?)(<\/I>|<\/i>)", "gi");
        var regexTABLE = new RegExp("(<table|<TABLE)[^>]*>(.*?)(<\/TABLE>|<\/table>)", "gi");
        var regexH1 = new RegExp("(<h1|<H1)[^>]*>(.*?)(<\/H1>|<\/h1>)", "gi");
        var regexH2 = new RegExp("(<h2|<H2)[^>]*>(.*?)(<\/H2>|<\/h2>)", "gi");
        var regexEM = new RegExp("(<em|<EM)[^>]*>(.*?)(<\/EM>|<\/em>)", "gi");
        var regexA = new RegExp("(<a|<A)[^>]*>(.*?)(<\/A>|<\/a>)", "gi");
        var regexUL = new RegExp("(<ul|<UL)[^>]*>(.*?)(<\/UL>|<\/ul>)", "gi");

        function OnClientPasteHtml1(editor, args) {
            var commandName = args.get_commandName();
            var value = args.get_value();

            if (commandName == "Paste") {

                var pasteContent = value;
                pasteContent = pasteContent.replace(regexOpenDIV, "<P>");
                pasteContent = pasteContent.replace(regexCloseDIV, "</P>");
                pasteContent = pasteContent.replace(regexP, "<P>$2</P>").replace(regexWhiteSpace, " ");
                pasteContent = pasteContent.replace(regexSpan, "");
                /*pasteContent = pasteContent.replace(regexFont, "");*/
                pasteContent = pasteContent.replace(regexFont, "$2");
                pasteContent = pasteContent.replace(regexStrong, "");
                pasteContent = pasteContent.replace(regexB, "$2");
                pasteContent = pasteContent.replace(regexU, "$2");
                pasteContent = pasteContent.replace(regexI, "$2");
                pasteContent = pasteContent.replace(regexTABLE, "");
                pasteContent = pasteContent.replace(regexH1, "<P>$2</P>");
                pasteContent = pasteContent.replace(regexH2, "<P>$2</P>");
                pasteContent = pasteContent.replace(regexEM, "$2");
                pasteContent = pasteContent.replace(regexA, "$2");

                pasteContent = pasteContent.replace(/size|SIZE = ([\d]{1})/g, '');

                // plain text
                //if (!pasteContent.match(/(<([^>]+)>)/gi))
                pasteContent = "<P>" + pasteContent + "</P>";

                //set the modified pasted content in the editor
                args.set_value(pasteContent);
            }
        }

        function OnClientCommandExecuted(editor, args) {
            if ("ApplyClass" == args.get_commandName()) {
                var content = editor.get_html(true);
                content = content.replace(/span/gi, "p");
                editor.set_html(content);
            }
        }


        // Insert Image From List Into Editor Content
        Telerik.Web.UI.Editor.CommandList["CustomImageManager"] = function (commandName, radEditorContent, args) {
            var insertImageCallbackFunction = function (sender, args) {
                if (!args.IsCancel) {
                    var html = GetImageAttribute(args);
                    radEditorContent.pasteHtml(html);
                }
            };
            // Indent
            Telerik.Web.UI.Editor.CommandList["CustomerIndent"] = function (commandName, editor, args) {
                editor.pasteHtml('<span style="width:200px;border: 1px dashed #bb0000;background-color: #fafafa;color: blue;"> ' + args.get_value() + ' </span>');
            };

            radEditorContent.showExternalDialog(
            '' + '/Admin/Modules/FileManager/InsertFTPImage.aspx', {},
            800, 620, insertImageCallbackFunction, null, null, true,
            Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, false, true);
        };

        // Insert Document From List Into Editor Content
        Telerik.Web.UI.Editor.CommandList["CustomDocumentManager"] = function (commandName, radEditorContent, args) {

            var argument = radEditorContent.getSelectionHtml();
            var insertDocumentCallbackFunction = function (sender, args) {
                if (!args.IsCancel) {
                    var html = GetDocumentAttribute(args);
                    radEditorContent.pasteHtml(html);
                }
            };

            radEditorContent.showExternalDialog(
        '' + '/Admin/Modules/FileManager/InsertFTPDocument.aspx', argument,
        780, 550, insertDocumentCallbackFunction, null, null, true,
        Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, false, true);
        };

        // Flash Video
        Telerik.Web.UI.Editor.CommandList["CustomVideoManager"] = function (commandName, radEditorContent, args) {
            var insertVideoCallbackFunction = function (sender, args) {
                if (!args.IsCancel) {
                    var html = GetVideoAttribute(args);
                    radEditorContent.pasteHtml(html);
                }
            }

            radEditorContent.showExternalDialog(
            '' + '/Admin/Modules/FileManager/InsertVideo.aspx', {},
            800, 620, insertVideoCallbackFunction, null, null, true,
            Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move, false, true);
        };

        // Insert Custom Audio
        Telerik.Web.UI.Editor.CommandList["CustomAudioManager"] = function (commandName, radEditorContent, args) {
            var insertAudioCallbackFunction = function (sender, args) {
                if (!args.IsCancel) {
                    var html = GetAudioAttribute(args);
                    radEditorContent.pasteHtml(html);
                }
            }

            radEditorContent.showExternalDialog(
            '' + '/Admin/Modules/FileManager/InsertAudio.aspx',
            {},
            800,
            620,
            insertAudioCallbackFunction,
            null,
            null,
            true,
            Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
            false,
            true);
        };
    </script>
</asp:Content>

